#include<stdio.h>
#include<fcntl.h>
//利用fdopen函数转换为FILE结构体指针
int main(void)
{
	FILE *fp;
	int fd=open("data.txt",O_WRONLY|O_CREAT|O_TRUNC);
	if(fd==-1)
	{
		fputs("file open error",stdout);
		return -1;
	}
	//FILE *fdopen(int fildes,const char* mode)
	fp=fdopen(fd,"w");
	fputs("Network C programming\n",fp);
	fclose(fp);
	return 0;
}
